package com.freen.fadmin.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class CorsConfiguration implements WebMvcConfigurer {
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/SysApi/**")
                // 只允许本地的9000端口访问
                .allowedOrigins(
                        "http://118.24.102.230",
                        "http://localhost:9527",
                        "http://118.24.102.230:8089",
                        "*"
                        //, "http://127.0.0.1:9000"
                )
                //设置允许前端获取的字段，token 但是目前用的vue admin 过滤了header 所以这里不用了。
                //.exposedHeaders("token")
                // 允许发送Cookie
                .allowCredentials(true)
                // 允许所有方法
                .allowedMethods("GET", "POST", "PUT", "DELETE", "HEAD");
    }
}
